﻿<!-- 行为安全观察与沟通频次管理 -->
<!--By Songyf-->
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>

<body>
    
<div id="app" v-cloak>   

    <el-form label-position="right" ref="form" :inline="true" :model="formInline" class="demo-form-inline"
             style="margin-bottom: 15px;">
        <el-row>
            <el-col class="head-tool">
                <div class="new_title fl"><strong><img src="/static/images/icon1.png" />行为安全观察与沟通频次管理列表</strong></div>
                <span>
                    <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3" @click="onSubmit">
                    </btn>
                    <btn :text="col.btnAdd" linetype="3" @click="UserInput('tj')"></btn>
                    <btn :text="col.btnDelete" linetype="4" @click="onDelete"></btn>
                </span>
            </el-col>
        </el-row>
        <el-row class="popupW100">
            <list-factorys v-model="formInline.model.createFactory" @change="factoryChange"></list-factorys>
            <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input size="mini">
                            <template slot="prepend">
                                {{STOPInformationManagement.department+mark.m}}
                                
                            </template>
                            <treeselect v-model="formInline.model.department"
                                        :options="department"
                                        :flat="true"
                                        :show-count="true"
                                        slot="suffix"
                                        style="line-height: 28px;"
                                        placeholder="请选择" />
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>

            <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input size="mini">
                            <template slot="prepend">
                                {{STOPInformationManagement.observePeople+mark.m}}
                            </template>
                            <tree-department-staff-single-jgstop slot="suffix" v-model="formInline.model.name" style="line-height:28px;"></tree-department-staff-single-jgstop>
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>
        </el-row>
    </el-form>
        <el-col :span="24">
            <el-table ref="table" stripe :data="ListItem.tableData" :height="ListItem.tableHeight" border
                @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%">
                <!--:span-method="objectSpanMethod"-->
                <el-table-column type="selection" align="center" width="55">
                </el-table-column>
                <el-table-column type="index" :label="col.SequenceNumber" :index="indexMethod" width="50"
                    show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop="sysDepartment.name" align="center" width="100" label="部门">
                </el-table-column>
                <el-table-column prop="sysDuty.name" align="center" width="100" label="岗位">
                </el-table-column>
                <el-table-column prop="sysUser.name" :label="BehaviorSafetyCommunicationFrequency.name" width="100">
                </el-table-column>
                <el-table-column prop="frequencyText" :label="BehaviorSafetyCommunicationFrequency.Frequency" min-width="150"
                show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column width="53" prop="update" :label="col.btnUpdate" fixed="right">
                    <template slot-scope="scope">
                        <button type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                            <i class="el-icon-edit"></i>
                        </button>
                    </template>
                </el-table-column>
            </el-table>
            <el-row type="flex" justify="end">
                <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes" :page-size="ListItem.pagesize"
                    :layout="ListItem.layout" :total="ListItem.total">
                </el-pagination>
            </el-row>
        </el-col>
        <el-dialog  fullscreen="true"  title="行为安全观察与沟通频次管理" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%"
            height="80%" top="10vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
        <!--:fullscreen="true"-->
    </div>
    <script type="text/javascript">
         Vue.component('tree-department-staff-single-jgstop', {
            props: ['value', 'multiple'],
            data: function () {
                return {
                    options: [],
                    valueConsistsOf: "LEAF_PRIORITY"
                }
            },
            methods: {
                input: function (v, instanceId) {
                    console.log(v);
                    this.$emit('input', v);
                },
                getData: function () {
                    var app = this;
                    myAjax("Get", null, "/api/JG_STOPObserveMain/GetTreeDepartmentStaff", null, function (response) {
                        var ajaxModel = response.data;
                        app.options = PersonMenuHelper(ajaxModel, guidEmpty);
                    }, false);
                }
            },
            mounted: function () {
                this.getData();
            },
            template: ' <treeselect :multiple="multiple"     :disable-branch-nodes="true"   :value-consists-of="valueConsistsOf"  :options="options"    v-model="value" @input="input"  />'

        })
        Vue.component('treeselect', VueTreeselect.Treeselect)
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    //页面内数据初始化
                    ListItem: ListItem,
                    department: [],
                    formInline: {
                        model: {
                            createFactory:null,
                            department: null,
                            Objective: '',
                            name: null
                        },
                        offset: 0,
                        limit: 10
                    },
                }
            },
            created: function () {
                var currApp = this;
                window.onresize = function () {
                    currApp.ListItem.tableHeight = window.innerHeight -
                        currApp.$refs.table.$el.offsetTop - 60;
                    if (currApp.ListItem.tableHeight < 112) {
                        currApp.ListItem.tableHeight = 112;
                    }

                }
            },
            mounted: function () {

                
                //初始化数据
                var test = this.formInline;
                this.GetPageData(1);
                
        
                //列表高度自适应
                tablehigh(this);
            },
            methods: {
                factoryChange: function () {
                    this.getDepartmentData();
                    
                },
                //初始化部门下拉树
                getDepartmentData: function () {
                    
                    var mythis = this;
                    var test = mythis.formInline;
                    myAjax("post", this, '/api/SysDepartment/GetList', { model: { Name: '', Code: '', CreateFactory: mythis.formInline.model.createFactory }, offset: 0, limit: 999 }, function (response) {
                        mythis.department = menuHelperX(response.data.pageData, guidEmpty)
                    }, false);
                },
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                closeDialog: function () { closeDialog(this); },
                //删除方法
                onDelete: function () { onDelete(this, '/api/JG_STOPTimes/DeleteMuti'); },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "BehaviorSafetyCommunicationFrequencyInput.html", id); },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/JG_STOPTimes/GetList') },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                onSubmit: function () {
                    var test = this.formInline;
                    onSubmit(this);
                }
            }
        });

         //下拉树数据格式化
        function menuHelperX(list, pid) {
            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelperX(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }

    </script>
</body>

</html>